<?php

namespace app\admin\service;

use app\admin\dao\AccountBillDao;
use app\admin\model\UM as UM;
use ShidianUtil\Utils\TimeUtil;

/**
 * Class BillStatisticsService
 * @package app\admin\service
 */
class BillStatisticsService
{
    // dao
    private AccountBillDao $accountBillDao;

    public function __construct(AccountBillDao $accountBillDao)
    {
        $this->accountBillDao = $accountBillDao;
    }

    /**
     * 统计
     * @param UM|null $user
     * @param $memberId
     * @param $type
     * @param $billType
     * @param $accountType
     * @param $startTime
     * @param $endTime
     * @param $kw
     * @return array
     */
    public function read(?UM $user, $memberId, $type, $billType, $accountType, $startTime, $endTime, $kw): array
    {
        if(is_numeric($endTime)){
            $endTime = TimeUtil::stamp(TimeUtil::DAY, $endTime, false);
        }
        return $this->accountBillDao->statisticsListBill($memberId, $type, $billType, $accountType, $startTime, $endTime, $kw);
    }

}
